﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucPost.ascx.cs" Inherits="WCrawler.Controls.ucPost" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>
<%@ Register Src="~/Controls/ucTreeViewTopic.ascx" TagName="ucTreeViewTopic" TagPrefix="UserControl" %>
<%@ Register Src="~/Controls/ucHostFile.ascx" TagName="ucHostFile" TagPrefix="UserControl" %>
<%@ Register Src="~/Controls/ucImage.ascx" TagName="ucImage" TagPrefix="UserControl" %>
<%@ Register Src="~/Controls/ucSearchIMDB.ascx" TagName="ucSearchIMDB" TagPrefix="UserControl" %>
<%@ Register Src="~/Controls/ucSearchHostFiles.ascx" TagName="ucSearchHostFiles" TagPrefix="UserControl" %>

<script type="text/javascript">
    function linkSelect(rowIndex) {
        var element = document.getElementById(rowIndex);
        element.scrollIntoView(true);
    }

//    function setScroll(val) {
//        //document.Form1.scrollPos.value = val.scrollTop;
//        document.getElementById('scrollPos').value = val.scrollTop;
//    }

//    function scrollTo(what) {
//        document.getElementById(what).scrollTop = document.Form1.scrollPos.value;
//    }
</script>

<style type="text/css">
        .BackgroundStyle
        {
            background-color: #f3f3f3;
            filter: alpha(opacity=50);
            opacity: 0.5;
        }
        
        td
        {
            vertical-align: top;
        }
        
        <%--#tr_gridview
        {
        	height: 500px;
        }--%>
        
        #td_treeview
        {
            width: 200px;
        }
        
        #td_gridview
        {
            width: 400px;
        }
                
        .cpHeader
        {
            color: white;
            background-color: #719DDB;
            font: bold 11px auto "Trebuchet MS", Verdana;
            font-size: 12px;
            cursor: pointer;
            width:450px;
            height:18px;
            padding: 4px;           
        }
        .cpBody
        {
            background-color: #DCE4F9;
            font: normal 11px auto Verdana, Arial;
            border: 1px gray;               
            width:450px;
            padding: 4px;
            padding-top: 7px;
        }     
        
        .div_scroll
        {
        	width: 100%; 
        	height:500px; 
        	overflow: scroll;
        }
        
        .div_scroll1
        {
        	width: 100%; 
        	height:600px; 
        	overflow: scroll;
        }
        
        #div_treeview
        {
            width:200px;
            overflow: auto;
            border: 1px solid #CCCCCC;
            margin: 1em 0;
        }
    .style1
    {
        width: 150px;
    }
    </style>
    
<asp:UpdatePanel ID="SearhThreadUpdatePanel" runat="server">
    <ContentTemplate>
        
        <asp:DetailsView ID="detailsViewPost" runat="server" AutoGenerateRows="False" BorderStyle="Solid"
            CellPadding="4" DataKeyNames="PostId" DataSourceID="Post2LinqDataSource" ForeColor="#333333"
            GridLines="None" Height="50px" OnItemDeleted="detailsViewPost_ItemDeleted" OnItemInserted="detailsViewPost_ItemInserted"
            Width="100%" OnDataBound="detailsViewPost_DataBound" 
            OnItemUpdated="detailsViewPost_ItemUpdated" 
            onpageindexchanging="detailsViewPost_PageIndexChanging">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
            <EditRowStyle BackColor="#999999" />
            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
            <Fields>
                <asp:TemplateField HeaderText="PostTitle" SortExpression="PostTitle">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtPostTitle" runat="server" Text='<%#Bind("PostTitle") %>' Width="100%"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblPostTitle" runat="server" Text='<%#Eval("PostTitle") %>' Width="100%"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tags" SortExpression="TagList">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtTagList" runat="server" Text='<%#Bind("TagList") %>' Width="100%"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblTagList" runat="server" Text='<%#Eval("TagList") %>' Width="100%"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Source Url" SortExpression="SourceUrl">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtSourceUrl" runat="server" Text='<%#Bind("SourceUrl") %>' Width="100%"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:HyperLink ID="hyperLinkSourceUrl" runat="server" NavigateUrl='<%#Eval("SourceUrl")  %>'
                            Text='<%#Eval("SourceUrl")  %>' Width="100%"></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Topic" SortExpression="Topic.TopicName">
                    <EditItemTemplate>
                        <asp:DropDownList ID="dropDownListThread" runat="server" AutoPostBack="True" DataSourceID="TopicLinqDataSource"
                            DataTextField="TopicName" DataValueField="TopicId" SelectedValue='<%#Bind("TopicId") %>'
                            Width="100%">
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblThread" runat="server" Text='<%#Eval("Topic.TopicName") %>' Width="100%"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Create on" SortExpression="CreateOn">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtCreateOn" runat="server" Text='<%#Bind("CreateOn") %>' Width="100%"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCreateOn" runat="server" Text='<%#Eval("CreateOn") %>' Width="100%"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="HostFolder" SortExpression="HostFolder">
                    <EditItemTemplate>
                        <asp:TextBox ID="txtHostFolder" runat="server" Text='<%#Bind("HostFolder") %>' Width="100%"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblHostFolder" runat="server" Text='<%#Eval("HostFolder") %>' Width="100%"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        </asp:DetailsView>
        <table style="width: 100%">
            <tr>
                <td>
                    <div class="div_scroll1">
                        <asp:PlaceHolder runat="server" ID="PlaceHolderTreeViewTopic">
                            <UserControl:ucTreeViewTopic ID="ucTreeViewTopic" runat="server" OnBubbleIndexChanged="ucTreeViewTopic_SelectedIndexChanged" />
                        </asp:PlaceHolder>
                    </div>
                </td>
                <td id="td_tabcontainer" colspan="1" rowspan="1">
                    <div>
                        <asp:Label ID="Label1" runat="server" Text="Filter post"></asp:Label>
                        <asp:DropDownList ID="dropDownListIsApproved" runat="server" Height="22px" Width="248px"
                            AutoPostBack="True" OnSelectedIndexChanged="dropDownListIsApproved_SelectedIndexChanged">
                            <asp:ListItem Selected="True"></asp:ListItem>
                            <asp:ListItem>Approved</asp:ListItem>
                            <asp:ListItem>Not Approved</asp:ListItem>
                        </asp:DropDownList>
                        <asp:Button ID="btnApprove" runat="server" OnClick="btnApprove_Click" Text="Approve" />
                        <asp:Button ID="btnSelectedIndex" runat="server" Text="Focus selected row" Enabled="True" />
                        <input id="btnTest" type="button" onclick="<%= btnSelectedIndex.Text %>" value="Focus selected row" />
                    </div>
                    <ajaxToolkit:TabContainer ID="TabContainerPost" runat="server" ActiveTabIndex="2"
                        Width="100%">
                        <ajaxToolkit:TabPanel ID="TabPanelPost" runat="server" HeaderText="Content">
                            <HeaderTemplate>
                                Post List</HeaderTemplate>
                            <ContentTemplate>
                                <div id="scrollArea" class="div_scroll">
                                    <asp:GridView ID="gridViewPosts" runat="server" AutoGenerateColumns="False" DataKeyNames="PostId"
                                        DataSourceID="PostLinqDataSource" AllowSorting="True" OnSelectedIndexChanged="gridViewPosts_SelectedIndexChanged"
                                        BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px"
                                        CellPadding="4" Width="100%" Height="100%" OnRowDataBound="gridViewPosts_RowDataBound">
                                        <EmptyDataTemplate>
                                            <asp:Label ID="lblEmptySearch" runat="server" Font-Bold="True" ForeColor="#0033CC">No Results Found....  
                                            </asp:Label>
                                        </EmptyDataTemplate>
                                        <Columns>
                                            <asp:CommandField ShowSelectButton="True" />
                                            <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                                                <HeaderTemplate>
                                                    <asp:CheckBox ID="chkHead" runat="server" onclick="changeCheckState(this);" />
                                                </HeaderTemplate>
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="chkCheckItem" runat="server" />
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="#" ItemStyle-HorizontalAlign="Center">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblNum" runat="server" />
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center"></ItemStyle>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="PostTitle" SortExpression="Title">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblPostTitle" runat="server" Text='<%#Eval("PostTitle")%>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Thread" SortExpression="Thread">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblThread" runat="server" Text='<%# Eval("Topic.TopicName") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Host Folder" SortExpression="HostFolder">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblHostFolder" runat="server" Text='<%# Eval("HostFolder") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Created" SortExpression="CreateOn">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblCreated" runat="server" Text='<%# Eval("CreateOn") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Approved" SortExpression="IsApproved">
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="chkIsApproved" runat="server" Checked='<%# Bind("IsApproved") %>'>
                                                    </asp:CheckBox>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                        <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                                        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                                        <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                                        <RowStyle BackColor="White" ForeColor="#330099" />
                                        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                                        <SortedAscendingCellStyle BackColor="#FEFCEB" />
                                        <SortedAscendingHeaderStyle BackColor="#AF0101" />
                                        <SortedDescendingCellStyle BackColor="#F6F0C0" />
                                        <SortedDescendingHeaderStyle BackColor="#7E0000" />
                                    </asp:GridView>
                                </div>
                            </ContentTemplate>
                        </ajaxToolkit:TabPanel>
                        <ajaxToolkit:TabPanel ID="TabPanelPostDetails" runat="server" HeaderText="Content">
                            <HeaderTemplate>
                                Content</HeaderTemplate>
                            <ContentTemplate>
                                <asp:DetailsView ID="detailsViewPostDetails" runat="server" AutoGenerateRows="False"
                                    DataKeyNames="PostDetailsId" DataSourceID="PostDetailsLinqDataSource" Height="50px"
                                    Width="100%" AllowPaging="True" OnDataBound="detailsViewPostDetails_DataBound"
                                    OnItemInserting="detailsViewPostDetails_ItemInserting">
                                    <Fields>
                                        <asp:TemplateField HeaderText="Language" SortExpression="Language.LanguageName">
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="LanguageDropDownList" runat="server" AutoPostBack="True" DataSourceID="LanguageLinqDataSource"
                                                    DataTextField="LanguageName" DataValueField="LanguageId" SelectedValue='<%# Bind("LanguageId") %>'>
                                                </asp:DropDownList>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="txtLanguage" runat="server" Text='<%# Bind("Language.LanguageName") %>'></asp:Label></ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Title" SortExpression="PostTitle">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtPostTitle" runat="server" Text='<%# Bind("PostTitle") %>' Font-Bold="True"
                                                    Font-Size="Small" Width="100%"></asp:TextBox></EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="lblPostTitle" runat="server" Text='<%# Bind("PostTitle") %>' Font-Bold="True"
                                                    Font-Size="Small" Width="100%"></asp:Label></ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Content" SortExpression="PostContent">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtEditPostContent" runat="server" Rows="20" Text='<%# Bind("PostContent") %>'
                                                    TextMode="MultiLine" Width="100%"></asp:TextBox></EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtPostContent" runat="server" ReadOnly="True" Rows="20" Text='<%# Bind("PostContent") %>'
                                                    TextMode="MultiLine" Width="100%"></asp:TextBox></ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Create on" SortExpression="CreateOn">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtCreateOn" runat="server" Text='<%# Bind("CreateOn") %>'></asp:TextBox></EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="lblCreateOn" runat="server" Text='<%# Bind("CreateOn") %>'></asp:Label></ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Update on" SortExpression="UpdateOn">
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtUpdateOn" runat="server" Text='<%# Bind("UpdateOn") %>'></asp:TextBox></EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:Label ID="lblUpdateOn" runat="server" Text='<%# Bind("UpdateOn") %>'></asp:Label></ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
                                    </Fields>
                                </asp:DetailsView>
                                <div>
                                    <asp:Button ID="btnVBulletin" runat="server" OnClick="btnHtmlCode_Click" Text="vBulletin Code" /><asp:Button
                                        ID="btnPhpBB2" runat="server" Text="phpbb2 Code" OnClick="btnPhpBB2_Click" /><asp:Button
                                            ID="btnPhpBB3" runat="server" OnClick="btnPhpBB3_Click" Text="phpbb3 Code" /><asp:Button
                                                ID="btnIPB" runat="server" Text="IPB Code" OnClick="btnIPB_Click" /></div>
                            </ContentTemplate>
                        </ajaxToolkit:TabPanel>
                        <ajaxToolkit:TabPanel ID="TabPanelPostFiles" runat="server" HeaderText="Files">
                            <ContentTemplate>
                                <asp:PlaceHolder runat="server" ID="HostFilePlaceHolder">
                                    <UserControl:ucHostFile ID="ucHostFile" runat="server" />
                                </asp:PlaceHolder>
                            </ContentTemplate>
                        </ajaxToolkit:TabPanel>
                        <ajaxToolkit:TabPanel ID="TabPanelImage" runat="server" HeaderText="Images">
                            <HeaderTemplate>
                                Images</HeaderTemplate>
                            <ContentTemplate>
                                <asp:PlaceHolder runat="server" ID="PlaceHolderImage">
                                    <UserControl:ucImage ID="ucImage" runat="server" />
                                </asp:PlaceHolder>
                            </ContentTemplate>
                        </ajaxToolkit:TabPanel>
                        <ajaxToolkit:TabPanel ID="TabPanelSearchIMDB" runat="server" HeaderText="Search IMDB">
                            <HeaderTemplate>
                                Search IMDB</HeaderTemplate>
                            <ContentTemplate>
                                <asp:PlaceHolder runat="server" ID="PlaceHolderSearchIMDB">
                                    <UserControl:ucSearchIMDB ID="ucSearchIMDB" runat="server" />
                                </asp:PlaceHolder>
                            </ContentTemplate>
                        </ajaxToolkit:TabPanel>
                        <ajaxToolkit:TabPanel ID="TabPanelSearchHostFiles" runat="server" HeaderText="Search Host Files">
                            <ContentTemplate>
                                <asp:PlaceHolder runat="server" ID="PlaceHolderSearchHostFiles">
                                    <UserControl:ucSearchHostFiles ID="ucSearchHostFiles" runat="server" />
                                </asp:PlaceHolder>
                            </ContentTemplate>
                        </ajaxToolkit:TabPanel>
                    </ajaxToolkit:TabContainer>
                </td>
            </tr>
        </table>
        <div>
            <!-- Popup show full content-->
            <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
            <ajaxToolkit:ModalPopupExtender ID="mdlPopup" runat="server" PopupControlID="PanelHtmlCode"
                TargetControlID="btnShowPopup" BackgroundCssClass="BackgroundStyle">
            </ajaxToolkit:ModalPopupExtender>
            <asp:Panel ID="PanelHtmlCode" runat="server" BackColor="#ffffff" BorderColor="#dadada"
                BorderStyle="Solid" BorderWidth="4px" Width="800px" Font-Names="Arial" Font-Size="10pt">
                <table cellpadding="10" cellspacing="0" style="width: 100%">
                    <tr>
                        <td>
                            <asp:TextBox ID="txtHmtlCode" runat="server" Rows="10" Width="100%" TextMode="MultiLine"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="middle">
                            <asp:Button ID="btnCancel" runat="server" Text="Cancel" /><br />
                            <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
    
<asp:LinqDataSource ID="PostLinqDataSource" runat="server" 
    ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
    TableName="Posts" onselecting="PostLinqDataSource_Selecting">
</asp:LinqDataSource>
    <asp:LinqDataSource ID="Post2LinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" EntityTypeName="" 
        onselecting="Post2LinqDataSource_Selecting" TableName="Posts">
    </asp:LinqDataSource>
<asp:LinqDataSource ID="PostDetailsLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        TableName="PostDetails" onselecting="PostDetailsLinqDataSource_Selecting" 
        EnableDelete="True" EnableInsert="True" EnableUpdate="True">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="TopicLinqDataSource" runat="server" 
        ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
        TableName="Topics">
    </asp:LinqDataSource>
        <asp:LinqDataSource ID="LanguageLinqDataSource" runat="server" 
            ContextTypeName="WCrawlerLib.LinqDataClassesDataContext" EntityTypeName="" 
            TableName="Languages" OrderBy="LanguageName">
        </asp:LinqDataSource>

